/**
 * Created by yuyongzhen  <1640599564@qq.com>>.
 */

module.exports = function(mod,name){
	mod.service(name,['$http',function($http){
		return {
			getRealTimeStat: function(pageno,province,category){
				return $http({
					method: 'get',
					url: '/api/static/realtimestat',
					params: {
						pageno: pageno,
						pro: province,
						cate: category
					}
				});		
			},
			drawCharts: function($container,name,data){
				var series_1 = {
					name: name,
					data: []
				}	
				var categories = [];
				for(var key in data){
					categories.push(data[key]['times']);	
					series_1.data.push(parseInt(data[key]['total']));
				}
				console.log(series_1);
				$container.highcharts({
					title: {
						text: ''	
					},
					xAxis: {
						categories: categories	
					},
					credits: {
						enabled: false	
					},
					yAxis: {
						title: {
							text: '单位时间抓取量(条)'	
						},
						plotLines: [{
						    value: 0,
							width: 1,
							color: '#808080'
						}]
					},
					tooltip: {
						valueSuffix: '条'	
					},
					legend: {
						layout: 'horizontal',
						align: 'center',
						verticalAlign: 'bottom',
						borderWidth: 0
					},
					series: [
						series_1	
					]
				});
			}
		}	
	}]);
}


